package xxl.robotlegs.base.log 
{
	import xxl.robotlegs.core.ILogger;
	import xxl.robotlegs.core.ILogTarget;
	
	/**
	 * ...
	 * @author XXL
	 */
	public class LogManager implements ILogTarget 
	{
		private var _logLevel:int = LogLevel.INFO;
		private const _targets:Vector.<ILogTarget> = new Vector.<ILogTarget>();
		
		public function LogManager() 
		{
			
		}
		
		public function get logLevel():int 
		{
			return _logLevel;
		}
		
		public function set logLevel(value:int):void 
		{
			_logLevel = value;
		}
		
		public function getLogger(source:Object):ILogger
		{
			return new Logger(source, this);
		}
		
		public function addLogTarget(target:ILogTarget):void
		{
			_targets.push(target);
		}
		
		/* INTERFACE xxl.robotlegs.core.ILogTarget */
		
		public function log(source:Object, level:int, timestamp:int, message:String, params:Array = null):void 
		{
			if (level > _logLevel)
			{
				return;
			}
			const len:int = _targets.length;
			for (var i:int = 0; i < len; i++) 
			{
				_targets[i].log(source, level, timestamp, message, params);
			}
		}
		
	}

}